package com.yidu.t299.config;

import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author twj
 * @version 1.0.0
 */
@Configuration
public class HystrixDashboardConfig {
    /**
     *  Hystrix dashboard 监控界面必须配置
     */
    @Bean
    public ServletRegistrationBean getServlet() {
        //熔断器指标流控制器
        HystrixMetricsStreamServlet streamServlet = new HystrixMetricsStreamServlet();
        //控制器注册对象
        ServletRegistrationBean registrationBean = new ServletRegistrationBean(streamServlet);
        //配置所需参数：启动时加载、访问路径、名字
        registrationBean.setLoadOnStartup(1);
        registrationBean.addUrlMappings("/actuator/hystrix.stream");//访问路径
        registrationBean.setName("hystrix.stream");
        return registrationBean;
    }
}
